package com.tianlu.store.enums;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
@NoArgsConstructor
public enum ProductTypeEnum {
	/**
     * 	类型：1普通商品，2代理商礼包，3分公司礼包
	 */
	NORMAL(1,"普通商品"),
	AGENT(2,"代理商礼包"),
	COMPANY(3,"分公司礼包"),
	FREE(4,"免费商品"),
	SECKILL(5,"秒杀商品");

	private final static Map<Integer, ProductTypeEnum> map = new HashMap<>();
	
	public Integer value;
	public String text;

	/**
	 * 根据code获取去枚举对象
	 * @param value 消息编码
	 * @return ResponseMessage
	 */
	public static String findByCode(Integer value) {
		if (map.size() == 0) {
			for (ProductTypeEnum status : values()) {
				map.put(status.value, status);
			}
		}
		ProductTypeEnum statusEnum = map.get(value);
		if (statusEnum != null) {
			return statusEnum.text;
		}
		return "";
	}

}
